/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ec.com.farmaciassantamartha.comprobantes.portal.util;

import java.io.File;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;

/**
 *
 * @author Rolando
 */
public class Parser {

    public static AutorizacionWrapper unmarshall(String pathArchivo) throws Exception {
        JAXBContext context = JAXBContext.newInstance(AutorizacionWrapper.class);
        Unmarshaller unmarshaller = context.createUnmarshaller();
        AutorizacionWrapper item = (AutorizacionWrapper) unmarshaller.unmarshal(new File(pathArchivo));
        return item;
    }

    public static String getTagValue(String xml, String tagName) {
        return xml.split("<" + tagName + ">")[1].split("</" + tagName + ">")[0];
    }
}
